package com.zhuss.core.append;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.core.append.CreateUserAppendBo;
import com.zhuss.bean.bo.core.append.DeleteUserAppendBo;
import com.zhuss.bean.bo.core.append.UpdateUserAppendBo;
import com.zhuss.bean.bo.core.append.wechat.FocusUserBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * @description: 用户关注、点赞操作的Service
 * @author: zhushanshuo
 * @create: Fri Jul 03 20:49:22 CST 2020
 **/
@Component("userAppendOperateService")
public class UserAppendOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("userAppendCreate")
	private Processor<Object, CreateUserAppendBo> userAppendCreate;
	
	@Autowired
	@Qualifier("userAppendUpdate")
	private Processor<Object, UpdateUserAppendBo> userAppendUpdate;
	
	@Autowired
	@Qualifier("userAppendDelete")
	private Processor<Object, DeleteUserAppendBo> userAppendDelete;
	
	@Autowired
	@Qualifier("userFocus")
	private Processor<Object, FocusUserBo> userFocus;
	
	@Autowired
	@Qualifier("userDelFocus")
	private Processor<Object, FocusUserBo> userDelFocus;
	
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateUserAppendBo bo = (CreateUserAppendBo) param;
		
		userAppendCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateUserAppendBo bo = (UpdateUserAppendBo) param;
		
		userAppendUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteUserAppendBo bo = (DeleteUserAppendBo) param;
		
		userAppendDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 关注
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void focus(Object param) throws WpsException {
		
		FocusUserBo bo = (FocusUserBo) param;
		
		userFocus.process(bo);
		
		return null;
	}
	
	
	/**
	 * 取消
	 * 关注
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delFocus(Object param) throws WpsException {
		
		FocusUserBo bo = (FocusUserBo) param;
		
		userDelFocus.process(bo);
		
		return null;
	}
	
}

